home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 123
/
(Vol 123) Jan 13 2011.iso
/
Games
/
ping_ai.swf
/
scripts
/
frame_4
/
PlaceObject2_25_3
/
CLIPACTIONRECORD onClipEvent(enterFrame).as
next >
Wrap
Text File
|
2011-01-13
|
4KB
|
143 lines
onClipEvent(enterFrame){
function trajectory()
{
angle = Math.atan(ymov / xmov) * 180 / math.pi;
if(ymov >= 0 and xmov >= 0)
{
trajectory = Number(angle);
quad = 1;
}
else if(ymov >= 0 and xmov < 0)
{
quad = 2;
trajectory = 180 + Number(angle);
}
else if(ymov < 0 and xmov < 0)
{
trajectory = 180 + Number(angle);
quad = 3;
}
else if(ymov < 0 and xmov >= 0)
{
trajectory = 360 + Number(angle);
quad = 4;
}
}
if(this._parent.go == "yes")
{
if(this._parent.movie_height < this._y + this._height / 2)
{
_Y = this._parent.movie_height - this._height / 2;
updateAfterEvent();
ymov = - ymov;
}
else if(this._y - this._height / 2 < 0)
{
_Y = this._height / 2;
updateAfterEvent();
ymov = - ymov;
}
if(this._parent.left.hitTest(this) or this._parent.right.hitTest(this))
{
if(this._parent.left.hitTest(this))
{
paddle = "left";
_root.Left_s.start();
_X = this._parent.left._x + this._parent.left._width / 2 + this._width / 2;
updateAfterEvent();
}
else if(this._parent.right.hitTest(this))
{
paddle = "right";
_root.Right_s.start();
_X = this._parent.right._x - this._parent.right._width / 2 - this._width / 2;
updateAfterEvent();
}
if(this._parent.level == "one")
{
factor = 0.1;
}
else if(this._parent.level == "two")
{
factor = 0.2;
}
else if(this._parent.level == "three")
{
factor = 0.4;
}
current_speed = math.sqrt(xmov * xmov + ymov * ymov) + factor;
if(_root.filter < current_speed)
{
current_speed = _root.filter;
}
trajectory();
if(paddle == "right")
{
shift = (- max_shift) * (this._parent.right._y - this._y) / (this._parent.right._height / 2);
}
else if(paddle == "left")
{
shift = max_shift * (this._parent.left._y - this._y) / (this._parent.left._height / 2);
}
trajectory += shift;
if(rot_filter < trajectory + shift and trajectory + shift < 180 - rot_filter or rot_filter + 180 < trajectory + shift and trajectory + shift < 360 - rot_filter)
{
if(0 < trajectory and trajectory < 90)
{
trajectory = rot_filter;
}
else if(90 < trajectory and trajectory < 180)
{
trajectory = 180 - rot_filter;
}
else if(180 < trajectory and trajectory < 270)
{
trajectory = 180 + rot_filter;
}
else if(270 < trajectory and trajectory < 360)
{
trajectory = 360 - rot_filter;
}
}
angle = trajectory * math.pi / 180;
xmov = current_speed * math.cos(angle);
ymov = current_speed * math.sin(angle);
xmov = - xmov;
}
_Y = this._y + ymov;
_X = this._x + xmov;
ball_shift = 0;
if(this._x < -20)
{
_root.Out.start();
_Y = 150;
_X = 300;
setProperty("_root.popup", _visible, 1);
if(_root.level == "one")
{
_root.popup.gotoAndStop(3);
}
else if(_root.level == "two")
{
_root.popup.gotoAndStop(4);
}
else if(_root.level == "three")
{
_root.popup.gotoAndStop(5);
}
xmov = 0;
ymov = 0;
}
else if(this._parent.movie_width + 20 < this._x)
{
_root.Out.start();
_Y = 150;
_X = 300;
setProperty("_root.popup", _visible, 1);
_root.popup.gotoAndStop(2);
xmov = 0;
ymov = 0;
}
}
}